package com.example.libo.huihui.activity;

import android.databinding.DataBindingUtil;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.example.libo.huihui.R;
import com.example.libo.huihui.application.MyApplication;
import com.example.libo.huihui.been.SearchResultOneEntity;
import com.example.libo.huihui.been.SearchResultTwoEntity;
import com.example.libo.huihui.databinding.ActivitySearchResultBinding;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class SearchResultActivity extends AppCompatActivity implements Callback<SearchResultOneEntity> {
    private ActivitySearchResultBinding binding;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(SearchResultActivity.this,R.layout.activity_search_result);

        init();
    }

    private void init() {
        String key = getIntent().getStringExtra("key");
        MyApplication.getHttpService().getSearchResult(key).enqueue(this);
        MyApplication.getHttpService().getSearchTwo(key).enqueue(new Callback<SearchResultTwoEntity>() {
            @Override
            public void onResponse(Call<SearchResultTwoEntity> call, Response<SearchResultTwoEntity> response) {

            }

            @Override
            public void onFailure(Call<SearchResultTwoEntity> call, Throwable t) {

            }
        });
    }

    @Override
    public void onResponse(Call<SearchResultOneEntity> call, Response<SearchResultOneEntity> response) {
        binding.tvShow.setText(response.body().getData().toString());
    }

    @Override
    public void onFailure(Call<SearchResultOneEntity> call, Throwable t) {

    }
}
